﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows.Data;

#if !SILVERLIGHT
using UIT.WPF.Converters;

namespace UIT.WPF.Renderers
#else
using UIT.Silverlight.Converters;

namespace UIT.Silverlight.Renderers
#endif
{
#if !SILVERLIGHT
    class BorderRenderer : 
        WpfRenderer<Controls.Border, Border>
#else
    public class BorderRenderer :
        SlRenderer<Controls.Border, Border>
#endif
    {
        public override void Render(Controls.Border control)
        {
            Result = new Border();
            Result.DataContext = control;
            Result.OnApplyTemplate();
            Result.SetBinding(Control.BackgroundProperty, new Binding("Style.Background") { Converter = new BrushConverter(Result.Background) });
            var renderer = Manager.Control.GetRenderer(control.Child);
            renderer.Render(control.Child);
#if !SILVERLIGHT
            IWpfRenderer wpfRenderer = renderer as IWpfRenderer;
#else
            ISlRenderer wpfRenderer = renderer as ISlRenderer;
#endif
            if (wpfRenderer != null)
                Result.Child = wpfRenderer.Result;
        }
    }
}
